package com.twu.biblioteca;

import java.nio.channels.IllegalBlockingModeException;

/**
 * Created by sravanns on 19/06/14.
 */
public class Quit implements Login{
    private UserInterface UIApplication;

    public Quit(Library lib, UserInterface ui) {

        UIApplication =ui;
    }

    @Override
    public String toString() {
        return "Quit";
    }

    @Override
    public ResultLogin performAction() throws IllegalBlockingModeException {
        UIApplication.display("Confirm log out YES or NO");
        Result result=new Result();
        ResultLogin resultLogin=new ResultLogin();
        if(UIApplication.acceptTitle().equalsIgnoreCase("yes")) {
            throw new IllegalBlockingModeException();

        }
        else {
            result.setResult("failed to quit",false);
            resultLogin.setResultLogin(null,result);

            return resultLogin;
        }
    }

}
